﻿@using Orchard.Autoroute.ViewModels;
@model AutoroutePartViewModel
@inject IAuthorizationService AuthorizationService;

<fieldset class="form-group" asp-validation-class-for="Path">
    <label asp-for="Path">@T["Permalink"] <span asp-validation-for="Path"></span></label>
    <input asp-for="Path" class="form-control" disabled="@(!Model.Settings.AllowCustomPath)"/>
    @if (!String.IsNullOrWhiteSpace(Model.Settings.Pattern) && Model.Settings.AllowCustomPath)
    {
        <span class="hint">@T["The url of the content item. Leave empty to auto-generate it."]</span>
    }
    else
    {
        <span class="hint">@T["The url of the content item. It will be automatically generated."]</span>
    }
</fieldset>

@{
    var authorized = await AuthorizationService.AuthorizeAsync(User, Permissions.SetHomepage);
    var showHomepageOption = Model.Settings.ShowHomepageOption && authorized;
}

@if (Model.IsHomepage) 
{
    <div class="alert alert-info">@T["This content item is the current homepage"]</div>
}
else
{
    if (showHomepageOption)
    {
        <fieldset class="form-check">
            <label class="form-check-label">
                <input asp-for="SetHomepage" type="checkbox" class="form-check-input" checked="@Model.SetHomepage" /> @T["Set as homepage"]
                <span class="hint">@T["Check to set this content item as the homepage once published."]</span>
            </label>
        </fieldset>
    }
}